# -*- conding:UTF-8 -*-

'''
@ Project: P8 hw register_login
@ File: create_flask.py
@ Author: 罗婷
@ Date：2022/6/16 16:46

'''
from flask import Flask
from flask_cors import CORS
from common.models import db
from views.comments import comment_bp
from views.courses import courses_bp
from views.learnInfo import learn_bp
from views.oauth_user import oauth_user_bp
from views.pay import pay_bp
from views.users import user_bp
from views.vip import vip_bp


def create_flask_app(info):
    app = Flask(__name__)
    app.config.from_object(info)
    # 跨域 蓝图 初始化 钩子
    CORS(app)

    app.register_blueprint(user_bp)
    app.register_blueprint(oauth_user_bp)
    app.register_blueprint(courses_bp)
    app.register_blueprint(comment_bp)
    app.register_blueprint(learn_bp)
    app.register_blueprint(vip_bp)
    app.register_blueprint(pay_bp)

    db.init_app(app)

    return app



